<?php require("inc/common.inc.php");?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport">
<?php
$id=intval($id);
if($id==""){
    $fun->popmassage("非法操作，系统将自动返回上一页!","","popback");
    exit();
}
  $sqlsel="select *  from mx_vpp_youhuiquan where id='$id' and isok='1' and isdelete='0' limit 1";
  $rs=$db->excu($sqlsel);
  if ($db->num_rows($rs)<=0){
    $fun->popmassage("非法操作，系统将自动返回上一页!","","popback");
    exit();
  }
  $newsdb=$db->fetch_array($rs);
  $article_title="$newsdb[name]";
  $article_title2="$newsdb[name] ";

 
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><?php echo $article_title;?></title>
<meta name="searchtitle" content="<?php echo $web_title2.$webdb['metakeywords'];?>">
<meta name="description" content="<?php echo $web_title2.$webdb['webdsc'];?>">
<meta name="keywords" content="<?php echo $web_title2.$webdb['metakeywords'];?>">
<link href="images/style.css" rel="stylesheet" type="text/css" />
</head>
<script language="javascript" src="js/jquery_min.js"></script>
<body style="background:#d4f3ff;">
<?php
$head_hide=1;
require("w_head.php");
?>
<div id="yhq_con">
	<div class="t1"><?php echo $newsdb["name"];?></div>
	<div class="t2">
	<?php
	echo "有效期：".date("Y-m-d ",strtotime($newsdb["startdate"]))." 至 ".date("Y-m-d ",strtotime($newsdb["enddate"]));
	?>
	</div>
	<div class="t3">
	<?php
	if (trim($newsdb["picurl"])!=""){
		echo "<img src=\"".get_photourl($newsdb["picurl"])."\">";
	}
	?>
	<div class="lingqu"><a href="javascript:yhq_ling()">领取优惠券</a></div>
   <div class="clear"></div>
   <div class="lingqu" style="margin-top:10px;"><a href="/my_yhq.php">我的优惠券</a></div>
	<?php echo str_replace("src=\"/upload_files/","src=\"http://weixin.mxsoft.cn/upload_files/",stripslashes($newsdb["content"]));?></div>
	</div>
	<div class="clear"></div>
</div>
<?php require("w_copyright.php");?>
<script type="text/javascript">
function yhq_ling(){ 
    $.ajax({ 
        type: 'GET', 
        url: 'yhq_ling.php?id=<?php echo $newsdb["id"];?>', 
        dataType: 'json', 
        cache: false, 
        error: function(){ 
            alert('出错了！'); 
            return false; 
        }, 
        success:function(json){ 
			var error = json.error;
			if (error != 0) {
				alert(error);
			} else {
				alert("恭喜您，优惠券已经领取成功");
			} 
        } 
    }); 
} 


        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        window.shareData = {  
           "imgUrl": "<?php echo get_photourl($newsdb["picurl"])?>", 
            "timeLineLink": "<?php echo $WEBURL;?>",
            "sendFriendLink": "<?php echo $WEBURL;?>",
            "weiboLink": "<?php echo $WEBURL;?>",
            "tTitle": "<?php echo $newsdb["title"]?>",
            "tContent": "<?php echo dvhtmlcode(strip_tags($newsdb["description"]))?>",
            "fTitle": "<?php echo $newsdb["title"]?>",
            "fContent": "<?php echo dvhtmlcode(strip_tags($newsdb["description"]))?>",
            "wContent": "<?php echo dvhtmlcode(strip_tags($newsdb["description"]))?>" 
        };
        // 发送给好友
        WeixinJSBridge.on('menu:share:appmessage', function (argv) {
            WeixinJSBridge.invoke('sendAppMessage', { 
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.sendFriendLink,
                "desc": window.shareData.fContent,
                "title": window.shareData.fTitle
            }, function (res) {
                _report('send_msg', res.err_msg);
            })
        });

        // 分享到朋友圈
        WeixinJSBridge.on('menu:share:timeline', function (argv) {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.timeLineLink,
                "desc": window.shareData.tContent,
                "title": window.shareData.tTitle
            }, function (res) {
                _report('timeline', res.err_msg);
            });
        });

        // 分享到微博
        WeixinJSBridge.on('menu:share:weibo', function (argv) {
            WeixinJSBridge.invoke('shareWeibo', {
                "content": window.shareData.wContent,
                "url": window.shareData.weiboLink,
            }, function (res) {
                _report('weibo', res.err_msg);
            });
        });
        }, false)
</script>
<script>

//弹出框中图片的切换
(function() {
var imgs = jQuery(".t3 img"),
imgsSrc = [],
minWidth = 0;
imgs.each(function() {
var jqthis = jQuery(this),
src = jqthis.attr('data-src') || jqthis.attr('src');
if (jqthis.width() >= minWidth && src && typeof(jqthis.parent().attr("href"))== "undefined") {
imgsSrc.push(src);
jqthis.on('click', function() {
reviewImage(src);
});
}
});

function reviewImage(src) {
if (typeof window.WeixinJSBridge != 'undefined') {
WeixinJSBridge.invoke('imagePreview', {
'current' : src,
'urls' : imgsSrc
});
}
}
    })();
</script>
</body>
</html>